<?php
/**
 * [模型]交易报表(淘宝数据)
 * 
 * @version $Id: Report.php 647 2013-01-23 06:39:11Z linsir123 $
 */
class adminReport
{
	/**
	 * 取得报告列表
	 * // 取出当天的所有
	 */
	public function getByDate($date)
	{
		$list = array();
		
		$p = 1;
		$show = 20;
		$totalPage = 1;
		while ($totalPage > 0) {
			$data = $this->_getTopList($date, $p, $show);
			$tmp = (array) $data['taobaoke_report']['taobaoke_report_members']['taobaoke_report_member'];
			$list = array_merge($list, $tmp);
			if ($p == 1) {
				$total = (int) $data['taobaoke_report']['total_results'];
				$totalPage = ceil($total/$show);
			}
			
			///
			$p++;
			$totalPage--;
		}
		
		return $list;
	}
	
	
	/// 以下为私有方法 ///
	
	
	/**
	 * 取得报告列表
	 * // 通过`total_results`确认是否拉取结束
	 */
	private function _getTopList($date, $p = 1, $show = 20)
	{
		return M::topRequest()->taobaokeReportGet(array('date' => $date, 
			'p' => $p, 'show' => $show));
	}
}
